<?php
/**
 * @package pmapi
 * @copyright Copyright (c)2014 Enrico Fagnoni
 * @license GNU General Public License version 3, or later
 *
 * @since 1.0.0
 */
 
defined('_JEXEC') or die;

if (!class_exists('LinkedDataView')) require(JPATH_COMPONENT.DS.'views'.DS.'linkeddata.php');

class PmapiViewOntology extends LinkedDataView
{
    protected 
        $shopperGroups=array(),
        $productCategories=array();
    
    
    protected function _computeETag()
    {
        return md5(serialize($this->productCategories).serialize($this->shopperGroups));
    }

     
    public function GET_RequestProcessor($tpl = null) 
    {
        $this->shopperGroups = (array) $this->get('ShopperGroups');
        $this->productCategories = (array) $this->get('ProductCategories');
        
        // cleanup product category images
        foreach ($this->productCategories as $category) {
            $category->show_images =  ApiHelper::filterAndRebaseImages('category',$category->images);
        }
        
        return parent::GET_RequestProcessor($tpl);
    }
}